package manager;
import java.util.Set;

import entity.Book;
import entity.User;

import java.util.ArrayList;
import java.util.List;

/**
 * @author s759487
 * @version 1.0
 * @created 11-Apr-2011 16:27:27
 */
public class BookManager {

	private List<Book> books = new ArrayList<Book>();

	public BookManager(){
		addBook("Thomas Mann", "Der kleine Herr Friedmann", 0, null, null);
		addBook("Franz Kafka", "Die Verwandlung", 1, null, null);
		addBook("Selim Oezdogan", "Es Ist So Einsam Im Sattel Seit Das Pferd Tot Ist", 2, null, null);
	}

	public List<Book> findAll(){
		return books;
	}
	
	public Book findById(int id) {
		for (Book b: books) {
			if (id == b.getId()) {
				return b;
			}
		}
		return null;
	}
	
	public void addBook(String author, String title, int id, User user, User user2) {
		Book b = new Book();
		b.setId(id);
		b.setAuthor(author);
		b.setTitle(title);
                b.setLentTo(user);
                b.setReservedBy(user2);
		books.add(b);
	}

}